/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PanelConsulta.java
 *
 * Created on 17/02/2011, 02:18:45 PM
 */

package besa_adaptado;

import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;


/**
 *
 * @author Ayllu
 */
public class PanelConsulta extends javax.swing.JFrame {
    private static JFrame miFrame=null;
    /** Creates new form PanelConsulta */
    private PanelConsulta() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanelppal = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtaPerfilUsuario = new javax.swing.JTextArea();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtaPerfilDispositivo = new javax.swing.JTextArea();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jtaPerfilLocalizacion = new javax.swing.JTextArea();
        jLabel4 = new javax.swing.JLabel();
        jtfConsulta = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jspRespuesta = new javax.swing.JScrollPane();
        jtfRespuesta = new javax.swing.JTextArea();
        jButton2 = new javax.swing.JButton();
        jcbDispositivo = new javax.swing.JComboBox();
        jcbUsuario = new javax.swing.JComboBox();
        jcbLocalizacion = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jtaPerfilUsuario.setColumns(20);
        jtaPerfilUsuario.setEditable(false);
        jtaPerfilUsuario.setRows(5);
        jScrollPane1.setViewportView(jtaPerfilUsuario);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18));
        jLabel1.setText("Perfil Usuario");

        jtaPerfilDispositivo.setColumns(20);
        jtaPerfilDispositivo.setEditable(false);
        jtaPerfilDispositivo.setRows(5);
        jScrollPane2.setViewportView(jtaPerfilDispositivo);

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 18));
        jLabel2.setText("Perfil Dispositivo");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 18));
        jLabel3.setText("Perfil Localizacion");

        jtaPerfilLocalizacion.setColumns(20);
        jtaPerfilLocalizacion.setEditable(false);
        jtaPerfilLocalizacion.setRows(5);
        jtaPerfilLocalizacion.setText("\n\n");
        jScrollPane3.setViewportView(jtaPerfilLocalizacion);

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 18));
        jLabel4.setText("Consulta");

        jButton1.setText("Consultar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 18));
        jLabel5.setText("Respuesta");

        jtfRespuesta.setColumns(20);
        jtfRespuesta.setEditable(false);
        jtfRespuesta.setRows(5);
        jspRespuesta.setViewportView(jtfRespuesta);

        jButton2.setText("Salir");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jcbDispositivo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "RT50", "Nokia", "Samsung" }));

        jcbUsuario.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Juan", "Pepe", "John" }));

        jcbLocalizacion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Fernando Barón", "Central", "Basicas" }));

        javax.swing.GroupLayout jPanelppalLayout = new javax.swing.GroupLayout(jPanelppal);
        jPanelppal.setLayout(jPanelppalLayout);
        jPanelppalLayout.setHorizontalGroup(
            jPanelppalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelppalLayout.createSequentialGroup()
                .addGap(47, 47, 47)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 156, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(56, 56, 56))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelppalLayout.createSequentialGroup()
                .addContainerGap(234, Short.MAX_VALUE)
                .addComponent(jLabel4)
                .addGap(218, 218, 218))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelppalLayout.createSequentialGroup()
                .addContainerGap(225, Short.MAX_VALUE)
                .addComponent(jLabel5)
                .addGap(212, 212, 212))
            .addGroup(jPanelppalLayout.createSequentialGroup()
                .addGap(99, 99, 99)
                .addGroup(jPanelppalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jspRespuesta, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE)
                    .addComponent(jtfConsulta, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 322, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButton1)
                .addGap(21, 21, 21))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelppalLayout.createSequentialGroup()
                .addContainerGap(468, Short.MAX_VALUE)
                .addComponent(jButton2)
                .addContainerGap())
            .addGroup(jPanelppalLayout.createSequentialGroup()
                .addGroup(jPanelppalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelppalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jcbLocalizacion, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jcbDispositivo, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanelppalLayout.createSequentialGroup()
                            .addGap(44, 44, 44)
                            .addComponent(jLabel3))
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 253, Short.MAX_VALUE))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelppalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jcbUsuario, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)))
        );
        jPanelppalLayout.setVerticalGroup(
            jPanelppalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelppalLayout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addGroup(jPanelppalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelppalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jcbDispositivo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jcbUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(2, 2, 2)
                .addGroup(jPanelppalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanelppalLayout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jcbLocalizacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(1, 1, 1)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelppalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtfConsulta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel5)
                .addGap(18, 18, 18)
                .addComponent(jspRespuesta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelppal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanelppal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        String consulta = jtfConsulta.getText();
        if(!consulta.contains(" ")){
            JOptionPane.showMessageDialog(null,"Minimo 2 palabras siendo la segunda el tema","Error", JOptionPane.ERROR_MESSAGE);
            jtfConsulta.selectAll();
        }else{
            CreadorEjemplo ej = new CreadorEjemplo(consulta);
            ej.lanzarEjemplo();
        }
        
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        JOptionPane.showMessageDialog(null, "Gracias!","Agradecimiento",JOptionPane.INFORMATION_MESSAGE);
        System.exit(0);
    }//GEN-LAST:event_jButton2ActionPerformed

    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPanel jPanelppal;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JComboBox jcbDispositivo;
    private javax.swing.JComboBox jcbLocalizacion;
    private javax.swing.JComboBox jcbUsuario;
    public static javax.swing.JScrollPane jspRespuesta;
    private javax.swing.JTextArea jtaPerfilDispositivo;
    private javax.swing.JTextArea jtaPerfilLocalizacion;
    private javax.swing.JTextArea jtaPerfilUsuario;
    private javax.swing.JTextField jtfConsulta;
    private javax.swing.JTextArea jtfRespuesta;
    // End of variables declaration//GEN-END:variables

    public JTextArea getJtfRespuesta() {
        return jtfRespuesta;
    }

    public JComboBox getJcbDispositivo() {
        return jcbDispositivo;
    }

    public JComboBox getJcbLocalizacion() {
        return jcbLocalizacion;
    }

    public JComboBox getJcbUsuario() {
        return jcbUsuario;
    }

    public JTextArea getJtaPerfilDispositivo() {
        return jtaPerfilDispositivo;
    }

    public JTextArea getJtaPerfilLocalizacion() {
        return jtaPerfilLocalizacion;
    }

    public JTextArea getJtaPerfilUsuario() {
        return jtaPerfilUsuario;
    }
    public static JFrame getInstance(){
        if(miFrame==null){
            miFrame = new PanelConsulta();
        }
        return miFrame;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        throw new CloneNotSupportedException();
    }
}
